struct Year(i64);
struct Days(i64);

impl Year {
    pub fn to_days(&self) -> Days {
        Days(self.0 * 365)
    }
}

impl Days {
    /// 舍去不满一年的部分
    pub fn to_years(&self) -> Year {
        Year(self.0 / 365)
    }
}

fn old_enough(age: &Year) -> bool {
    age.0 >= 18
}
fn main() {
    let age = Year(20);
    let age_days = age.to_days();
    println!("Old enough {}", old_enough(&age));
    println!("Old enough {}", old_enough(&age_days.to_years()));
    // println!("Old enougth {}", old_enough(&age_days));
    // ^ error[E0599]: no method named `to_years` found for type `Days` in the current scope
}
